import { ComponentType } from 'react';

// 直接导入布局组件
import MainLayout from '../layouts/MainLayout';

// 定义路由配置接口
export interface RouteConfig {
  path: string;
  element?: ComponentType<object> | JSX.Element;
  children?: RouteConfig[];
  auth?: boolean;
  permission?: string;
  title?: string;
  icon?: string;
  redirect?: string;
  hideInMenu?: boolean;
  index?: boolean;
  keepAlive?: boolean;
}

// 直接导入组件
import Login from '../views/login/Login';
import News from '../views/news/News';
import Detail from '../views/news/Detail';
// 从正确的目录导入管理组件
import NewsAdd from '../views/sandbox/news-manage/NewsAdd';
import NewsDraft from '../views/sandbox/news-manage/NewsDraft';
// 移除找不到的组件导入
// import NewsPreview from '../views/sandbox/news-manage/NewsPreview';
// import NewsUpdate from '../views/sandbox/news-manage/NewsUpdate';
import NewsCategory from '../views/sandbox/news-manage/NewsCategory';
import Home from '../views/sandbox/home/Home';
// 移除Dashboard导入
// import Dashboard from '../views/sandbox/home/Dashboard';
import UserList from '../views/sandbox/user-manage/UserList';
import RoleList from '../views/sandbox/right-manage/RoleList';
import RightList from '../views/sandbox/right-manage/RightList';
// import RegionList from '../views/sandbox/news-manage/RegionList';
import Audit from '../views/sandbox/audit-manage/Audit';
import AuditList from '../views/sandbox/audit-manage/AuditList';
import Unpublished from '../views/sandbox/publish-manage/Unpublished';
import Published from '../views/sandbox/publish-manage/Published';
import Sunset from '../views/sandbox/publish-manage/Sunset';
import UserProfile from '../views/sandbox/user-profile/UserProfile';
import Settings from '../views/sandbox/system-settings/Settings';
// import NewsList from '../views/sandbox/news-manage/NewsList';

// 错误页面
import NotFound from '../views/NotFound';

// 公共路由 - 不需要权限
export const publicRoutes: RouteConfig[] = [
  {
    path: '/login',
    element: Login,
    title: '登录'
  },
  {
    path: '/news',
    element: News,
    title: '新闻列表'
  },
  {
    path: '/detail/:id',
    element: Detail,
    title: '新闻详情'
  }
];

// 受保护路由 - 需要权限
export const protectedRoutes: RouteConfig[] = [
  {
    path: '/',
    element: MainLayout,
    auth: true,
    children: [
      {
        path: 'home',
        element: Home,
        auth: true,
        permission: '/home',
        title: '首页',
        icon: 'HomeOutlined',
        keepAlive: true
      },
      // 移除Dashboard路径配置
      // 个人中心
      {
        path: 'user-profile',
        element: UserProfile,
        auth: true,
        permission: '/user-profile',
        title: '个人中心',
        icon: 'UserOutlined'
      },
      // 用户管理
      {
        path: 'user-manage/list',
        element: UserList,
        auth: true,
        permission: '/user-manage/list',
        title: '用户列表',
        icon: 'UserOutlined'
      },
      // 权限管理
      {
        path: 'right-manage/role/list',
        element: RoleList,
        auth: true,
        permission: '/right-manage/role/list',
        title: '角色列表',
        icon: 'TeamOutlined'
      },
      {
        path: 'right-manage/right/list',
        element: RightList,
        auth: true,
        permission: '/right-manage/right/list',
        title: '权限列表',
        icon: 'SafetyCertificateOutlined'
      },
      // 新闻管理
      /*
      {
        path: 'news-manage/list',
        element: NewsList,
        auth: true,
        permission: '/news-manage/list',
        title: '新闻列表',
        icon: 'UnorderedListOutlined',
        keepAlive: true
      },
      */
      {
        path: 'news-manage/add',
        element: NewsAdd,
        auth: true,
        permission: '/news-manage/add',
        title: '撰写新闻',
        icon: 'EditOutlined'
      },
      {
        path: 'news-manage/add/:id',
        element: NewsAdd,
        auth: true,
        permission: '/news-manage/add',
        title: '编辑新闻',
        hideInMenu: true
      },
      {
        path: 'news-manage/draft',
        element: NewsDraft,
        auth: true,
        permission: '/news-manage/draft',
        title: '草稿箱',
        icon: 'FileOutlined',
        keepAlive: true
      },
      {
        path: 'news-manage/category',
        element: NewsCategory,
        auth: true,
        permission: '/news-manage/category',
        title: '新闻分类',
        icon: 'AppstoreOutlined'
      },
      /*
      {
        path: 'news-manage/region',
        element: RegionList,
        auth: true,
        permission: '/news-manage/region',
        title: '区域管理',
        icon: 'GlobalOutlined'
      },
      */
      /*
      {
        path: 'news-manage/preview/:id',
        element: NewsPreview,
        auth: true,
        permission: '/news-manage/preview',
        title: '新闻预览',
        hideInMenu: true
      },
      */
      /*
      {
        path: 'news-manage/update/:id',
        element: NewsUpdate,
        auth: true,
        permission: '/news-manage/update',
        title: '更新新闻',
        hideInMenu: true
      },
      */
      // 审核管理
      {
        path: 'audit-manage/audit',
        element: Audit,
        auth: true,
        permission: '/audit-manage/audit',
        title: '审核新闻',
        icon: 'AuditOutlined'
      },
      {
        path: 'audit-manage/list',
        element: AuditList,
        auth: true,
        permission: '/audit-manage/list',
        title: '审核列表',
        icon: 'OrderedListOutlined',
        keepAlive: true
      },
      // 发布管理
      {
        path: 'publish-manage/unpublished',
        element: Unpublished,
        auth: true,
        permission: '/publish-manage/unpublished',
        title: '待发布',
        icon: 'UploadOutlined',
        keepAlive: true
      },
      {
        path: 'publish-manage/published',
        element: Published,
        auth: true,
        permission: '/publish-manage/published',
        title: '已发布',
        icon: 'CheckCircleOutlined',
        keepAlive: true
      },
      {
        path: 'publish-manage/sunset',
        element: Sunset,
        auth: true,
        permission: '/publish-manage/sunset',
        title: '已下线',
        icon: 'StopOutlined',
        keepAlive: true
      },
      // 系统设置
      {
        path: 'system/settings',
        element: Settings,
        auth: true,
        permission: '/system/settings',
        title: '系统设置',
        icon: 'SettingOutlined'
      },
      // 404页面要放在最后
      {
        path: '*',
        element: NotFound,
        hideInMenu: true
      }
    ]
  }
];

export default {
  publicRoutes,
  protectedRoutes
}; 